<template>
  <div class="page-home">
    <div class="home-entry">
      <div class="container">
        <!-- 左侧分类 -->
        <HomeCategory />
        <!-- 轮播图 -->
        <home-carousel
          class="home-banner" 
          :bannerList="bannerList"
        />
        <!-- 新鲜好物 -->
        <home-new/>
        <!-- 人气推荐 -->
        <home-hot/>
        <!-- 热门品牌 -->
        <home-brand/>
        <!-- 商品区域 -->
        <HomeProduct />
        <!-- 最新专题 -->
        <HomeSpecial />
      </div>
    </div>
  </div>
</template>
<script>
import HomeCategory from './components/home-category'
import HomeCarousel from './components/home-carousel.vue'
import HomeNew from './components/home-new'
import HomeHot from './components/home-hot.vue'
import HomeBrand from './components/home-brand.vue'
import HomeProduct from './components/home-product.vue'
import HomeSpecial from './components/home-special.vue'
import { findBanner } from '@/api/home'
import { ref } from 'vue'
export default {
  name: 'PageHome',
  components: {
    HomeCategory,
    HomeCarousel,
    HomeNew,
    HomeHot,
    HomeBrand,
    HomeProduct,
    HomeSpecial
  },
  setup () {
    // 用来储存请求接口获取的轮播图数据
    let bannerList = ref([])
    findBanner().then(res => {
      bannerList.value = res.result
    }).catch(err => {
      console.log(err)
    })
    return {
      bannerList
    }
  }
}
</script>
<style scoped lang="less">
.container {
  position: relative;
  .home-banner {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
  }
}
</style>